<ui:composition template="../index/index.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:define name="content">
		<h:form>

			<h:panelGrid columns="2">
				<h:outputLabel value="Tipo de Gráfico: " for="tipoGrafico" />
				<h:selectOneMenu id="tipoGrafico"
					value="#{orcamentoBean.tipoGrafico}">
					<f:selectItem itemLabel="Barra" itemValue="BARRA" />
					<f:selectItem itemLabel="Linha" itemValue="LINHA" />
					<f:selectItem itemLabel="Pizza" itemValue="PIZZA" />
				</h:selectOneMenu>
				
				<h:outputText value="Data Inicial: " />
				<p:calendar value="#{orcamentoBean.dataInicial}" />

				<h:outputText value="Data Final: " />
				<p:calendar value="#{orcamentoBean.dataFinal}" />
				
				<h:outputText value="Granularidade: " />
				<h:selectOneMenu value="#{orcamentoBean.step}">
					<f:selectItem itemLabel="Dia" itemValue="DIA" />
					<f:selectItem itemLabel="Mes" itemValue="MES" />
					<f:selectItem itemLabel="Ano" itemValue="ANO" />
				</h:selectOneMenu>

				<h:outputLabel value="Eixo Y: " for="eixoY" />
				<h:selectOneMenu id="eixoY" value="#{orcamentoBean.eixoY}">
					<f:selectItem itemLabel="Número de Pedidos de Orçamento"
						itemValue="N_PEDIDOS" />
					<f:selectItem itemLabel="Valor Total de Pedidos de Orçamento"
						itemValue="VAL_PEDIDOS" />
				</h:selectOneMenu>

				<h:outputText value="Planos de Saúde: " />
				<h:selectManyCheckbox layout="pageDirection"
					value="#{orcamentoBean.planosSelecionados}">
					<c:forEach var="plano" items="#{orcamentoBean.planosList}">
						<f:selectItem itemLabel="#{plano.nome}" itemValue="#{plano.id}" />
					</c:forEach>
				</h:selectManyCheckbox>

			</h:panelGrid>

			<h:commandButton action="#{orcamentoBean.gerarGrafico}"
				value="Gerar Gráfico" />

		</h:form>

		<h:panelGroup rendered="#{orcamentoBean.tipoGrafico == 'BARRA'}">
			<p:barChart id="basic" value="#{orcamentoBean.categoryModel}"
				legendPosition="ne" min="0"
				max="#{orcamentoBean.maxEixoY}" style="height:300px" />
		</h:panelGroup>

		<h:panelGroup rendered="#{orcamentoBean.tipoGrafico == 'LINHA'}">
			<p:lineChart id="linear" value="#{orcamentoBean.categoryModel}"
				legendPosition="e" minY="0"
				maxY="#{orcamentoBean.maxEixoY}" style="height:300px" />
		</h:panelGroup>

		<h:panelGroup rendered="#{orcamentoBean.tipoGrafico == 'PIZZA'}">
			<p:pieChart id="sample" value="#{orcamentoBean.pieModel}"
				legendPosition="w" 
				style="width:400px;height:300px" />
		</h:panelGroup>

	</ui:define>
</ui:composition>